package com.yanqu.road.server.manager.activity.jiuzhou.task;

import com.yanqu.road.logic.helper.ActivityHelper;
import com.yanqu.road.server.manager.activity.jiuzhou.CrossJiuZhouMgr;
import com.yanqu.road.server.manager.activity.jiuzhou.activity.CrossJiuZhouActivity;
import com.yanqu.road.utils.executor.GeneralTask;

import java.util.Map;

/**
 * 九州棋局
 */

public class CrossJiuZhouStageTask extends GeneralTask {
    
    @Override
    public void doRun() {
        Map<Integer, CrossJiuZhouActivity> activityMap = CrossJiuZhouMgr.getActivityMap();
        if (activityMap == null || activityMap.isEmpty()) {
            return;
        }
        for (CrossJiuZhouActivity activity : activityMap.values()) {
            if (activity.getConfig() != null && !ActivityHelper.activityInShowTime(activity.getConfig().getActivityInfo())) {
                continue;
            }
            try {
                //检测阶段转换
                activity.stageChangeTask();
                //检测是否需要锁定冠军
                activity.checkLockActivityChampion();
            } catch (Exception e) {
                getLOGGER().error("jiuzhou activity stage task error activityId{}: ", activity.getConfig().getActivityInfo().getActivityId(), e);
            }
        }
    }
}
